package com.revzone.demo001.entity.PermissionEntity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.revzone.demo001.entity.OtherEntity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(description = "接收用户参数信息")
public class UserRoleDTO extends BaseEntity<UserRoleDTO> implements Serializable {

    private static final long serialVersionUID = 1L;
//    用户数据

    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty("主键id")
    private Integer id;

    @TableField("user_name")
    @ApiModelProperty("姓名")
    private String userName;

    @TableField("nick_name")
    @ApiModelProperty("别名")
    private String nickName;

    @TableField("password")
    @ApiModelProperty("密码")
    private String password;

    @TableField("salt")
    @ApiModelProperty("盐")
    private String salt;

    @TableField("sex")
    @ApiModelProperty("性别")
    private Integer sex;

    @TableField("email")
    @ApiModelProperty("邮箱")
    private String email;

    @TableField("phone")
    @ApiModelProperty("电话")
    private String phone;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("创建时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("create_date")
    private Date createDate;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("修改时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("update_date")
    private Date updateDate;

    @TableField("status")
    @ApiModelProperty("状态")
    private Integer status;

    @TableField("remarks")
    @ApiModelProperty("备注")
    private String remarks;

//    角色数据

    @TableField("role_id")
    @ApiModelProperty("角色列表ID")
    private List<Integer> roleId;

    @TableField("role_name")
    @ApiModelProperty("角色名称")
    private String roleName;

    @TableField("roleNickName")
    @ApiModelProperty("角色别名")
    private String roleNickName;

    @TableField("menu_list")
    @ApiModelProperty("角色拆单列表ID")
    private List<Object> roleMenuList;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("角色创建时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("create_date")
    private Date roleCreateDate;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("角色修改时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("update_date")
    private Date roleUdateDate;

    @TableField("roleStatus")
    @ApiModelProperty("角色状态")
    private Integer roleStatus;

    @TableField("remarks")
    @ApiModelProperty("角色备注")
    private String roleRemarks;

//分页数据

    @ApiModelProperty("页数据条数")
    @TableField(exist = false)//非数据库字段
    public Long pageSize = 10L;

    @ApiModelProperty("当前为第几页")//非数据库字段
    @TableField(exist = false)
    public Long currentPage = 1L;

    public Role copyToRole() {
        Role role = new Role();
        if (this.getRoleId() != null){
            role.setId(this.roleId.get(0));
        }else role.setId(null);
        role.setRoleName(this.roleName);
        role.setNickName(this.roleNickName);
//        role.setMenuList(this.roleMenuList);
        role.setCreateDate(this.roleCreateDate);
        role.setUpdateDate(this.roleUdateDate);
        role.setStatus(this.roleStatus);
        role.setRemarks(this.roleRemarks);
        return role;
    }
}
